home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-2.iso / os2 / rsynth1.zip / def_pars.c < prev    next >
C/C++ Source or Header  |  1994-11-08  |  3KB  |  118 lines

  1. #include <config.h>
  2. /* $Id: def_pars.c,v 1.13 1994/11/08 13:30:50 a904209 Exp a904209 $
  3.  */
  4. char *def_pars_id = "$Id: def_pars.c,v 1.13 1994/11/08 13:30:50 a904209 Exp a904209 $";
  5. #include <stdio.h>
  6. #include <useconfig.h>
  7. #include <math.h>
  8. #include "proto.h"
  9. #include "getargs.h"
  10. #include "nsynth.h"
  11. #include "hplay.h"
  12.  
  13. klatt_global_t klatt_global;
  14.  
  15. /* default values for pars array from .doc file */
  16. klatt_frame_t def_pars =
  17. {
  18. #include "pars.def"
  19. };
  20.  
  21. #ifdef USE_RC_FILE
  22.  
  23. #define RC_FILE "/.sayrc";
  24.  
  25. /* Based on an idea by 
  26.  
  27.    John Cartmill   -  cartmill@wisconsin.nrlssc.navy.mil 
  28.  
  29.    The ability to read the user's  .sayrc file 
  30.    ( which has the same format as  the pars.def file) 
  31.  
  32.    Not enabled by default as I don't have one other than 
  33.    pars.def! to test it on and it does not handle comments  
  34.  
  35.  */
  36.  
  37. static void
  38. read_rc_file(void)
  39. {
  40.  char *home = getenv("HOME");
  41.  if (home)
  42.   {
  43.    char *path = malloc(strlen(home) + strlen(RC_FILE) + 1);
  44.    if (path)
  45.     {
  46.      FILE *f = fopen(strcat(strcpy(path, home), RC_FILE), "r");
  47.      if (f)
  48.       {
  49.        char string[256];
  50.        int i;
  51.        union
  52.         {
  53.          klatt_t def_pars;
  54.          long array[NPAR];
  55.         }
  56.        pars;
  57.        for (i = 0; i < NPAR; ++i)
  58.         {
  59.          fgets(string, sizeof(string), infp);
  60.          value = atoi(string);
  61.          pars.array[i] = value;
  62.         }
  63.        def_pars = pars.def_pars;
  64.        fclose(f);
  65.       }
  66.      free(path);
  67.     }
  68.   }
  69. }
  70.  
  71. #endif
  72.  
  73. int
  74. init_synth(argc, argv)
  75. int argc;
  76. char *argv[];
  77. {
  78.  double mSec_per_frame = 10;
  79.  int impulse = 0;
  80.  int casc = 0;
  81.  klatt_global.samrate = samp_rate;
  82.  klatt_global.quiet_flag = TRUE;
  83.  klatt_global.glsource = NATURAL;
  84.  klatt_global.f0_flutter = 0;
  85.  
  86. #ifdef USE_RC_FILE
  87.  read_rc_file();
  88. #endif
  89.  
  90.  argc = getargs("Synth paramters",argc, argv,
  91.                 "q", NULL, &klatt_global.quiet_flag, "Quiet - minimal messages",
  92.                 "I", NULL, &impulse,                 "Impulse glottal source",
  93.                 "c", "%d", &casc,                    "Number cascade formants",
  94.                 "F", "%d", &klatt_global.f0_flutter, "F0 flutter",
  95.                 "f", "%lg", &mSec_per_frame,         "mSec per frame",
  96.                 "t", "%d", &def_pars.TLTdb,          "Tilt dB",
  97.                 "x", "%d", &def_pars.F0hz10,         "Base F0 in 0.1Hz",
  98.                 NULL);
  99.  
  100.  if (casc > 0)
  101.   {
  102.    klatt_global.synthesis_model = CASCADE_PARALLEL;
  103.    klatt_global.nfcascade = casc;
  104.   }
  105.  else
  106.   klatt_global.synthesis_model = ALL_PARALLEL;
  107.  
  108.  if (impulse)
  109.   klatt_global.glsource = IMPULSIVE;
  110.  
  111.  klatt_global.nspfr = (klatt_global.samrate * mSec_per_frame) / 1000;
  112. #ifdef HAVE_NONSTDARITH
  113.  /* turn off strict IEEE compliance in favour of speed */
  114.  nonstandard_arithmetic();
  115. #endif
  116.  return argc;
  117. }
  118.